{extend name="app/admin/view/base.html"/}
{block name="resources"}
<style>
    .layui-card-body{
        display: flex;
        justify-content: space-around;
    }
    .layui-card-body .money{
        font-size: 20px;
        color: #000;
        font-weight: bold;
        margin-top: 10px;
        text-align: center;
        max-width: 250px;
    }
    .layui-card-body .subhead{
        font-size: 12px;
        margin-left: 3px;
        cursor: pointer;
    }
    .layui-table-box {
        overflow: inherit;
    }
    .layui-table-header {
        overflow: inherit;
    }
    .layui-table-header .layui-table-cell{overflow: inherit;}
    .ns-prompt .iconfont{font-size: 16px;color: rgba(0,0,0,0.7);cursor: pointer;font-weight: 500;margin-left: 3px;}
    .ns-prompt-con{font-weight: 500;text-align: left}
    .img_block_sty{width:40px;height:40px;}
    .img_sty{width:100%;height:100%;}
</style>

{/block}
{block name='main'}

<div class="ns-screen layui-collapse" lay-filter="selection_panel">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">筛选</h2>
        <form class="layui-colla-content layui-form layui-show">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <label class="layui-form-label">酒店名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="hotel_name" placeholder="请输入酒店名称" class="layui-input">
                    </div>
                </div>

            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">提交时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="start_time" readonly id="start_time" autocomplete="off" placeholder="开始时间" >
                        <i class="ns-calendar"></i>
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" name="end_time" readonly id="end_time" autocomplete="off" placeholder="结束时间" >
                        <i class="ns-calendar"></i>
                    </div>
                </div>
            </div>
            <input type="hidden" name="apply_state" />
            <div class="ns-form-row">
                <button class="layui-btn ns-bg-color" lay-submit lay-filter="search">筛选</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
    </div>
</div>





<div class="layui-tab ns-table-tab" lay-filter="apply_list_tab">
    <ul class="layui-tab-title">
        <li class="layui-this" lay-id="">全部</li>
        <li lay-id="0" data-type="apply_state">待审核</li>
        <li lay-id="2" data-type="apply_state">审核拒绝</li>
        <!--		<li lay-id="4" data-type="apply_state">待提交财务凭证</li>-->
        <!--		<li lay-id="2" data-type="apply_state">待财务审核</li>-->
        <li lay-id="1" data-type="apply_state">审核成功</li>
        <!--		<li lay-id="-2" data-type="apply_state">财务审核失败</li>-->
    </ul>
    <div class="layui-tab-content">

        <table id="account_list" lay-filter="account_list"></table>

    </div>
</div>
{/block}
{block name="script"}
{include file="hotel/order_delivery_action" /}
<script type="text/html" id="action">
    <div class="ns-table-btn">
        {{#  if(d.apply_state == 0){ }}
        <a class="layui-btn" href="javascript:orderDelivery('{{d.apply_id}}')">审核</a>
        {{#  } }}
<!--        <a class="layui-btn" lay-event="edit">编辑</a>-->
        <a class="layui-btn" lay-event="detail">详情</a>

       <!-- {{#  if(d.status == 1){  }}
        <a class="layui-btn" lay-event="frozen">关闭</a>
        {{#  }  }}
        {{#  if(d.status == -1){  }}
        <a class="layui-btn" lay-event="unfrozen">开启</a>
        {{#  }  }}
        <a class="layui-btn" lay-event="delete">删除</a>-->
    </div>
</script>

<script type="text/html" id="website_info">
    <div class="ns-table-tuwen-box">
        <div class="ns-img-box img_block_sty">
            {{#  if(d.hotel_img){  }}
            <img layer-src src="{{ns.img(d.hotel_img.split(',')[0])}}" class="img_sty"/>
            {{#  }else{  }}
            <img layer-src src="{:img($default_img.default_city_img)}" class="img_sty"/>
            {{#  }  }}
        </div>
        <div class="ns-font-box">
            <a href="javascript:;" class="ns-multi-line-hiding ns-text-color" title="{{d.hotel_name}}">{{d.hotel_name}}</a>
        </div>
    </div>
</script>

<script>
    var start_time,end_time,element;
    layui.use(['laydate','form', 'laytpl'], function () {
        var laydate = layui.laydate,
            laytpl = layui.laytpl,
            form = layui.form,
            element = layui.element,
            repeat_flag = false;

        form.render();

        //开始时间
        laydate.render({
            elem: '#start_time', //指定元素
            type: 'datetime'
            /* done: function(value, date, endDate){
                start_time = ns.date_to_time(value);
            } */
        });
        //结束时间
        laydate.render({
            elem: '#end_time', //指定元素
            type: 'datetime'
            /* done: function(value, date, endDate){
                end_time = ns.date_to_time(value);
            } */
        });

        element.on('tab(apply_list_tab)', function () {
            var type = this.getAttribute('data-type');
            if (type) {
                var id = this.getAttribute('lay-id');
                $("input[name='" + type + "']").val(id);
                $("button[lay-filter='search']").click()
            } else {
                $("input[name='apply_state']").val("");
                $("button[lay-filter='search']").click()
            }
        });

        /**
         * 搜索功能
         */
        form.on('submit(search)', function (data) {
            // data.field.start_time = start_time;
            // data.field.end_time = end_time;
            table.reload({
                page: {
                    curr: 1
                },
                where: data.field
            });
            return false;
        });

        var table = new Table({
            elem: '#account_list',
            url: ns.url("hotel://admin/hotel/apply"),
            cols: [
                [{
                    field: 'title',
                    title: '酒店信息',
                    unresize: 'false',
                    width: '15%',
                    templet: '#website_info',
                }, {

                    title: '地址',
                    unresize: 'false',
                    width: '25%',
                    templet: function (d) {
                        return d.full_address + d.address;
                    }
                }, {
                    field: 'name',
                    title: '联系人',
                    unresize: 'false',
                    width: '10%'
                }, {
                    field: 'telphone',
                    title: '联系电话',
                    unresize: 'false',
                    width: '10%'
                },  {
                    title: '审核状态',
                    unresize: 'false',
                    width: '10%',
                    templet: function (data) {
                        var str = '';
                        if (data.apply_state==0){
                            str = '待审核';
                        } else if(data.apply_state==1){
                            str = '审核通过';
                        } else {
                            str = '审核拒绝';
                        }
                        return str;
                    }
                }, {
                    title: '提交时间',
                    unresize: 'false',
                    width: '12%',
                    templet: function (res) {
                        if (res.create_time == 0) {
                            return '--';
                        } else {
                            return ns.time_to_date(res.create_time)
                        }
                    }
                }, {
                    title: '操作',
                    toolbar: '#action',
                    unresize: 'false',
                    width: '15%'
                }]
            ]
        });

        /**
         * 监听工具栏操作
         */
        table.tool(function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'detail': //详情
                    location.href = ns.url("hotel://admin/hotel/detail", {"apply_id": data.apply_id});
                    break;
                case 'edit': //编辑
                    location.href = ns.url("hotel://admin/hotel/edit", {"apply_id": data.apply_id});
                    break;
                case 'delete'://删除

                    layer.confirm('确定要删除该酒店吗?', function () {
                        if (repeat_flag) return;
                        repeat_flag = true;

                        $.ajax({
                            url: ns.url("hotel://admin/hotel/delete"),
                            data: {apply_id: data.apply_id},
                            dataType: 'JSON',
                            type: 'POST',
                            success: function (res) {
                                layer.msg(res.message);
                                repeat_flag = false;

                                if (res.code == 0) {
                                    table.reload();
                                }
                            }
                        });
                    });
                    break;

                case 'frozen'://冻结

                    layer.confirm('确定要关闭该酒店吗?', function () {
                        if (repeat_flag) return;
                        repeat_flag = true;

                        $.ajax({
                            url: ns.url("hotel://admin/hotel/frozen"),
                            data: {apply_id: data.apply_id,is_frozen:-1},
                            dataType: 'JSON',
                            type: 'POST',
                            success: function (res) {
                                layer.msg(res.message);
                                repeat_flag = false;

                                if (res.code == 0) {
                                    table.reload();
                                }
                            }
                        });
                    });

                    break;
                case 'unfrozen'://解冻

                    layer.confirm('确定要开启该酒店吗?', function () {
                        if (repeat_flag) return;
                        repeat_flag = true;

                        $.ajax({
                            url: ns.url("hotel://admin/hotel/frozen"),
                            data: {apply_id: data.apply_id,is_frozen:1},
                            dataType: 'JSON',
                            type: 'POST',
                            success: function (res) {
                                layer.msg(res.message);
                                repeat_flag = false;

                                if (res.code == 0) {
                                    table.reload();
                                }
                            }
                        });
                    });

                    break;
            }


        });




    })
</script>


<script>
    function closePass() {
        layer.close(layer_pass);
    }
</script>
{/block}